<template>
  <div>
    <h3>子组件</h3>
    <p>{{ message }}</p>
    <button @click="sendMessageToParent">发送消息到父组件</button>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  props: {
    message: {
      type: String,
      required: true
    }
  },
  emits: ['child-event'],
  setup(props, { emit }) {
    const sendMessageToParent = () => {
      emit('child-event', '这是来自子组件的消息');
    };

    return {
      sendMessageToParent
    };
  }
});
</script>